package com.bwie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.common.pojo.GroupBuyingActivityProducts;
import com.bwie.mapper.GroupBuyingLMapper;
import com.bwie.service.GroupBuyingLService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Service
@Log4j2
public class GroupBuyingLServiceImpl extends ServiceImpl<GroupBuyingLMapper, GroupBuyingActivityProducts> implements GroupBuyingLService {

    // 拼团商品列表、查询
@Override
public List<GroupBuyingActivityProducts> groupBuyingList() {
    LambdaQueryWrapper<GroupBuyingActivityProducts> wrapper = Wrappers.lambdaQuery();
    // 可以根据其他字段添加更多的查询条件
    return list(wrapper);
}
    // 拼团商品添加
    @Override
    public void groupBuyingAdd(GroupBuyingActivityProducts groupBuyingActivityProducts) {
        groupBuyingActivityProducts.setCreatedTime(new Date());
        save(groupBuyingActivityProducts);
    }

    // 拼团商品删除
    @Override
    public void groupBuyingDel(Long groupBuyingActivityProductId) {
        removeById(groupBuyingActivityProductId);
    }

    // 拼团商品修改
    @Override
    public void groupBuyingUpdate(GroupBuyingActivityProducts groupBuyingActivityProducts) {
        groupBuyingActivityProducts.setUpdatedTime(new Date());
        updateById(groupBuyingActivityProducts);
    }

}
